home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp1.arc / GETDOWNL.PAS < prev    next >
Pascal/Delphi Source File  |  1985-09-26  |  6KB  |  174 lines

  1. (*----------------------------------------------------------------------*)
  2. (*        Get_Download_Protocol --- Get File Transfer Protocol          *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Get_Download_Protocol : Transfer_Type ;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Function:   Get_Download_Protocol                                *)
  10. (*                                                                      *)
  11. (*     Purpose:    Gets file name and transfer protocol for download.   *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Transtyp := Get_Download_Protocol: Transfer_Type;             *)
  16. (*                                                                      *)
  17. (*     Remarks:                                                         *)
  18. (*                                                                      *)
  19. (*     Calls:    KeyPressed                                             *)
  20. (*               Async_Send                                             *)
  21. (*               Async_Receive                                          *)
  22. (*                                                                      *)
  23. (*----------------------------------------------------------------------*)
  24.  
  25. VAR
  26.    Transfer_Kind : Transfer_Type;
  27.    Transfer_Menu : Menu_Type;
  28.    I             : INTEGER;
  29.    Pacing_String : STRING[1];
  30.    OK_File_Name  : BOOLEAN;
  31.    Flag          : BOOLEAN;
  32.  
  33. BEGIN (* Get_Download_Protocol *)
  34.  
  35.                                    (* Set up menu for protocol inquiry *)
  36.  
  37.    WITH Transfer_Menu DO
  38.       BEGIN
  39.  
  40.          Menu_Size    := 9;
  41.  
  42.          Menu_Default := ORD( Default_Transfer_Type ) + 1;
  43.          IF Menu_Default > 9 THEN Menu_Default := 1;
  44.  
  45.          Menu_Row     := 10;
  46.          Menu_Column  := 20;
  47.          Menu_Tcolor  := Menu_Text_Color;
  48.          Menu_Bcolor  := BackGround_Color;
  49.          Menu_Fcolor  := Menu_Frame_Color;
  50.          Menu_Width   := 50;
  51.          Menu_Height  := 16;
  52.  
  53.       END;
  54.  
  55.    FOR I := 1 TO 9 DO
  56.       WITH Transfer_Menu.Menu_Entries[I] DO
  57.       BEGIN
  58.          Menu_Item_Row    := I;
  59.          Menu_Item_Column := 2;
  60.          CASE I OF
  61.             1:  Menu_Item_Text := 'a) Ascii';
  62.             2:  Menu_Item_Text := 'b) Xmodem (Checksum)';
  63.             3:  Menu_Item_Text := 'c) Xmodem (CRC)';
  64.             4:  Menu_Item_Text := 'd) Kermit';
  65.             5:  Menu_Item_Text := 'e) Telink';
  66.             6:  Menu_Item_Text := 'f) Modem7 (Checksum)';
  67.             7:  Menu_Item_Text := 'g) Modem7 (CRC)';
  68.             8:  Menu_Item_Text := 'h) Ymodem';
  69.             9:  Menu_Item_Text := 'i) Ymodem (Batch)';
  70.          END (* CASE *);
  71.       END;
  72.                                    (* Get transfer protocol *)
  73.  
  74.    Transfer_Menu.Menu_Title := 'Choose file transfer protocol for download:';
  75.  
  76.    Menu_Display_Choices( Transfer_Menu );
  77.    Transfer_Kind := Transfers[ Menu_Get_Choice( Transfer_Menu ,
  78.                                                 Dont_Erase_Menu ) ];
  79.  
  80.                                    (* Get file name to use if not *)
  81.                                    (* batch transfer              *)
  82.    Ok_File_Name := FALSE;
  83.    FileName     := '';
  84.  
  85.    IF Transfer_Kind IN [ Ascii, Xmodem_Chk, Xmodem_Crc, Ymodem ] THEN
  86.       BEGIN
  87.  
  88.          REPEAT
  89.  
  90.             GoToXY( 2 , 11 );
  91.             ClrEol;
  92.  
  93.             WRITE('Filename.Ext ? ');
  94.             READLN(FileName);
  95.  
  96.             ASSIGN(AFile,FileName);
  97.                (*$I- *)
  98.             RESET( AFile );
  99.                (*$I+ *)
  100.  
  101.             IF Int24Result <> 0 THEN
  102.                OK_File_Name := TRUE
  103.             ELSE
  104.                BEGIN
  105.                   OK_File_Name := YesNo( FileName + ' already exists, overwrite? ');
  106.                      (*$I-*)
  107.                   CLOSE( AFile );
  108.                      (*$I+*)
  109.                   GoToXY( 1 , WhereY );
  110.                   ClrEol;
  111.               END;
  112.  
  113.          UNTIL( OK_File_Name );
  114.  
  115.          ASSIGN( AFile, FileName );
  116.                (*$I- *)
  117.          REWRITE( AFile );
  118.                (*$I+ *)
  119.  
  120.          IF Int24Result <> 0 THEN
  121.             BEGIN
  122.                Transfer_Kind := None;
  123.                WRITELN;
  124.                WRITELN('*** Can''t open output file, download cancelled ***');
  125.             END;
  126.  
  127.       END  (* Get file name *);
  128.  
  129.                                    (* Set default delays for Ascii transfers *)
  130.    Char_Delay := 0;
  131.    Line_Delay := 0;
  132.  
  133.    CASE Transfer_Kind OF
  134.  
  135.       Xmodem_Crc,
  136.       Xmodem_Chk  :     (*$I-*)
  137.                      CLOSE( Afile );
  138.                         (*$I+*)
  139.       Telink,
  140.       Ymodem,
  141.       Ymodem_Batch:  BEGIN
  142.                         GoToXY( 2 , 11 );
  143.                         Use_Time_Sent := YesNo(' Stamp file with time/date '+
  144.                                                'provided by host? ');
  145.                      END;
  146.  
  147.       Ascii       :  BEGIN
  148.                         GoToXY( 2 , 12 );
  149.                         WRITE('Receiving file ', FileName );
  150.                         ClrEol;
  151.                         GoToXY( 2 , 13 );
  152.                         WRITE('Hit Alt-R to stop transfer.');
  153.                         ClrEol;
  154.                         DELAY( Two_Second_Delay );
  155.                            (*$I-*)
  156.                         CLOSE( AFile );
  157.                            (*$I+*)
  158.                      END;
  159.  
  160.       ELSE           ;
  161.  
  162.    END (* CASE *);
  163.                                    (* Return transfer protocol type *)
  164.  
  165.    Get_Download_Protocol := Transfer_Kind;
  166.  
  167.    DELAY( Two_Second_Delay );
  168.                                    (* Remove this window            *)
  169.    Restore_Screen( Saved_Screen );
  170.  
  171.    Reset_Global_Colors;
  172.  
  173. END   (* Get_Download_Protocol *);
  174.